Skip to content

Fix backup download link — missing file= query parameter#970

Merged
JulianPrieber merged 1 commit into
LinkStackOrg:mainfrom
uAliAmer:fix/backup-download-url
Jun 8, 2026
Merged

Fix backup download link — missing file= query parameter#970
JulianPrieber merged 1 commit into
LinkStackOrg:mainfrom
uAliAmer:fix/backup-download-url

Conversation

@uAliAmer

Copy link
Copy Markdown
Contributor

Bug

Backup files cannot be downloaded from the admin panel. Clicking a backup download button navigates the browser to the page URL instead of triggering a file download, and throws a JS error:

```
Uncaught TypeError: Cannot read properties of null (reading 'addEventListener')
```

Root Cause

The download link is generated with the filename as a bare query key:

```php
// Generates: /admin/backups/?filename.zip
url('admin/backups') . '/?' . $entry
```

But the download handler checks `$_GET['file']`:

```php
if (isset($_GET['file'])) {
$filename = $_GET['file'];
// ... serve file
}
```

Since `$_GET['file']` is never set, the handler is skipped and the page renders as HTML, causing the JS error.

Fix

```php
// Generates: /admin/backups?file=filename.zip
url('admin/backups') . '?file=' . $entry
```

Two corrections in one:

  1. Removed the stray `/` before `?`
  2. Changed `$entry` to `file=$entry` to match what the handler expects

Test

Verified on a self-hosted instance behind an nginx reverse proxy — backup downloads work correctly after this change.

The download link was generated as /admin/backups/?filename.zip
but the download handler checks $_GET['file'], so the handler
was never triggered. The browser navigated to the page instead
of downloading the file, causing a JS error.

Changed: url('admin/backups') . '/?' . $entry
To:      url('admin/backups') . '?file=' . $entry
@JulianPrieber JulianPrieber changed the base branch from main to beta June 8, 2026 20:59
@JulianPrieber JulianPrieber changed the base branch from beta to main June 8, 2026 21:19
@JulianPrieber JulianPrieber merged commit dfbfe47 into LinkStackOrg:main Jun 8, 2026
1 check was pending
JulianPrieber pushed a commit that referenced this pull request Jun 8, 2026
The download link was generated as /admin/backups/?filename.zip
but the download handler checks $_GET['file'], so the handler
was never triggered. The browser navigated to the page instead
of downloading the file, causing a JS error.

Changed: url('admin/backups') . '/?' . $entry
To:      url('admin/backups') . '?file=' . $entry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants